package ren.kane.phoenix.some.innerclass;

/**
 * 匿名内部类.
 *
 * @author renrk(1275) on 2018-10-28 12:07 PM
 **/
public class Anonymous {

    public static void main(String[] args) {
        Animal animal = new Animal() {
            public void eat() {
                System.out.println("eating");
            }

            public void sleep() {
                System.out.println("sleeping");
            }
        };
        animal.eat();
        animal.sleep();

        new Animal() {
            public void eat() {
                System.out.println("to eat");
            }

            public void sleep() {
            }
        }.eat();
    }
}
